<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/4
 * Time: 11:09
 */
//针对于用户的数据的封装，继承，多态
//面向对线的编程方法
class adminDb
{

    //客户的添加信息
    public function add_user($user, $password,$addtime)
    {
        $sql = "insert into customer(user,password,addtime) values('$user','$password','$addtime')";
        $dbConn = new DbCon();
        return $dbConn->add_price($sql);

    }

    //管理员的添加信息
    public function add_admin($user, $password,$addtime)
    {
        $sql = "insert into admin(user,pass,addtime) values('$user','$password','$addtime')";
        $dbConn = new DbCon();
        return $dbConn->add($sql);

    }


    //管理员的注册查询
    function selectAdminA($user)
    {
        $sql = "select * from admin where user='$user'";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
    //登陆查询
    function selectUser($user,$password)
    {
        $sql = "select * from admin where user='$user' and pass='$password'";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
    //新生查询
    function queryNewUser()
    {
        $sql = "select * from student order by id desc ";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
    //新生查询
    function querySelfNew($id)
    {
        $sql = "select * from student where id='$id'";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
    //任务的查询
    function selectTask($task_content)
    {
        $sql = "select * from task where task_content='$task_content'";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
    //小组的任务的查询
    function selectTaskAll($user)
    {
        $sql = "select * from task where task_admin='$user' order by id desc";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
    //所有的任务的查询
    function queryAllTasl()
    {
        $sql = "select * from task order by id desc";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
    //管理员的任务的查询
    function selectTaskAdmin($user)
    {
        $sql = "select * from task where task_admin='$user' order by id desc";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
    //管理员登陆查询
    function selectAdmin($user,$password)
    {
        $sql = "select * from admin where user='$user' and password='$password'";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
    function queryAdUpadte($user){
        $sql = "select * from admin where user='$user'and user not in('$user')";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
    //管理员修改信息
    function updateAdmin($id,$user,$pass,$class,$code,$tel,$img,$email,$addtime){
     $sql="update admin set user='$user',pass='$pass',className='$class',code='$code',tel='$tel',img='$img',email='$email',addtime='$addtime'where id='$id'";
     $dnConn=new DbCon();
     return $dnConn->modify($sql);

    }
    //修改邮箱配置
    function updateAdminEmail($user,$code,$email){
        $sql="update admin set emailCode='$code',email='$email'where user='$user'";
        $dnConn=new DbCon();
        return $dnConn->modify($sql);

    }
    //管理员修改信息
    function updateAdminPass($id,$user,$class,$code,$tel,$img,$email,$addtime){
        $sql="update admin set user='$user',className='$class',code='$code',tel='$tel',img='$img',email='$email',addtime='$addtime'where id='$id'";
        $dnConn=new DbCon();
        return $dnConn->modify($sql);

    }
    //管理员信息的查询
    function queryAdmin($user)
    {
        $sql = "select * from admin where user='$user'";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
    //管理员信息的查询
    function queryEmail($admin)
    {
        $sql = "select * from admin where user='$admin'";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
  //写入公告
    function addNotice($user,$content,$title,$addtime){
        $sql="insert into notice(no_admin,content,title,no_addtime) values('$user','$content','$title','$addtime')";
        $dbConn=new DbCon();
        return $dbConn->add($sql);

}
    //写入公任务
    function addTask($task_content,$admin,$date,$task_a,$userA,$remarks,$url,$addtime){
        $sql="insert into task(task_content,task_admin,time_over,task_a,user_a,remark,url,task_time) values
('$task_content','$admin','$date','$task_a','$userA','$remarks','$url','$addtime')";
        $dbConn=new DbCon();
        return $dbConn->add($sql);
    }

   //管理员删除公告
    function delNotice($id){
      $sql="delete from notice where id='$id'";
        $dbConn=new DbCon();
        return $dbConn->delete($sql);

    }
    //管理员删除任务
    function delTask($id){
        $sql="delete from task where id='$id'";
        $dbConn=new DbCon();
        return $dbConn->delete($sql);

    }
    //管理员删除任务携带的附件
    function delFile($id,$url){
        $sql="update task set url='$url' where id='$id'";
        $dbConn=new DbCon();
        return $dbConn->delete($sql);

    }
    //管理员删除用户上传的文件
    function delUserFile($id,$url){
        $sql="update task set file='$url' where id='$id'";
        $dbConn=new DbCon();
        return $dbConn->delete($sql);

    }

    //所有的公告查询
    function selectNotice($user)
    {
        $sql = "select * from notice where no_admin='$user'order by id DESC";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }


}